/**
 * 格式化数字处理
 */
function formatNumber(value: any) {
  if (typeof Number(value) !== 'number') {
    return
  }
  return String(value).replace(/(\d{3})(?=\d)/g, '$1,')
}

export default function useFormat() {
  const numberFormat = (val: any) => formatNumber(val)
  const moneyFormat = (val: any) => '￥ ' + formatNumber(val)
  return {
    numberFormat,
    moneyFormat
  }
}